$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    const mstform = $NG.getCmpApi("p_form_ndczjh_m")
    const dgrid1 = $NG.getCmpApi("")
    const getHeadValue = (str)=>mstform.getItem(str).getValue()

    if(page.oType == 'add'){
        mstform.getItem("u_nd").setValue({
            label:new Date().getFullYear(),
            value:new Date().getFullYear()
        })
    }

    useValuesChange(()=>{
        getCntCbInfoByPhid()
    },"p_form_ndczjh_m.u_htmc")

    // 获得合同信息
    function getCntCbInfoByPhid(){
        const phid = getHeadValue("u_htmc")
        if(!phid) return 
        $NG.execServer("getCntCbInfoByPhid",{phid},(res)=>{
            if(res.count == 0) return 
            const datas = JSON.parse(res.data)[0].extendObjects
            const arr = [
                {
                    key:"u_sccyllb",
                    value:{
                        label:datas.sccyllb_name,
                        value:datas.sccyllb_phid
                    }
                },
                {
                    key:"u_hylb",
                    value:{
                        label:datas.yjhylb_name,
                        value:datas.yjhylb_phid
                    }
                },
                {
                    key:"u_ywlb",
                    value:{
                        value:datas.ywlb_phid,
                        label:datas.ywlb_name
                    }
                },
                {
                    key:"u_htje",
                    value:datas.user_htje
                },
                {
                    key:"u_jhkgrq",
                    value:datas.user_htjhkssj
                },
                {
                    key:"u_zzssl",
                    value:datas.user_zzssl
                },
                {
                    key:"u_jhwgrq",
                    value:datas.user_htjhjssj
                },
                {
                    key:"u_sgzt",
                    value:{
                        label:datas.zxzt_name,
                        value:datas.zxzt_phid
                    }
                }
            ]
            setHeadValue(arr)
        })
    }



    // 赋值
    function setHeadValue(datas) {
        datas.forEach(item => {
            try {
                mstform.getItem(item.key).setValue(item.value)
            } catch (err) {
                console.log(`err`, err, item);
            }
        })
    }
})